package com.snowfeel.sfmall.core.exception;

import com.snowfeel.sfmall.core.enums.ResultCode;

public class BizException extends RuntimeException {

    private static final long serialVersionUID = 5317680961212299217L;

    /** 异常码 */
    private String code;

    /** 异常信息 */
    private String message;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public BizException(String code) {
        this.code = code;
    }

    public BizException(ResultCode responseCode) {
        super(responseCode.getMessage());
        this.code = responseCode.getMessage();
    }

    public BizException(String code, Throwable cause) {
        this.code = code;
        super.initCause(cause);
    }

    public BizException(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public BizException(String code, String message, Throwable cause) {
        this.code = code;
        this.message = message;
        super.initCause(cause);
    }

    @Override
    public String toString() {
        return "com.snowfeel.sfmall.core.exception.BizException{" +
                "code='" + code + '\'' +
                ", message='" + message + '\'' +
                '}';
    }

}
